
<?php 
	header("Content-Type: text/html;charset=utf-8");
	try{
		
		$pdo = new PDO('mysql:host=localhost; dbname=newbusiness', 'root', 'root');
		$userid   = $_POST['userid'];
		$userids  = $_POST['userids'];

		//查看学生学号是否存在
		$showid = "select * from member where userid='$userid'";
		$result_id = $pdo->query($showid);
		$aa =  $result_id->rowCount();

		//查看学生身份证号是否存在
		$showids = "select * from member where userids='$userids'";
		$result_ids = $pdo->query($showids);
		$bb =  $result_ids->rowCount();
		if($aa && ($bb==0)){
			echo '
				<div>
					<h1 align="center">你好！<font color="red">你的学号已经被注册</font></h1>
					<br>
					<p style="padding-left:100px;font-size:20px;">如果提交的学号占用，请联系我们！</p>
					<p style="padding-left:100px;font-size:20px;">QQ:728838939 </p>
					<br>
					<p align="center"><a href="index.html" style="font-size:25px; color:red;">点击返回</a></p>
					<p align="center">--大学生科技创新协会--</p>
				</div>
 			';
		}else if($bb && ($aa==0)){
			echo '
				<div>
					<h1 align="center">你好！<font color="red">你的身份证已经被注册</font></h1>
					<br>
					<p style="padding-left:100px;font-size:20px;">如果提交的身份证占用，请联系我们！</p>
					<p style="padding-left:100px;font-size:20px;">QQ:728838939 </p>
					<br>
					<p align="center"><a href="index.html" style="font-size:25px; color:red;">点击返回</a></p>
					<p align="center">--大学生科技创新协会--</p>
				</div>
 			';
		}else if($aa && $bb){
			echo '
				<div>
					<h1 align="center">你好！你<font color="red">已经提交过信息</font>了，点击查看信息查看报名信息。</h1>
					<br>
					<p style="padding-left:100px;font-size:22px;">请将查看页面进行截图。</p>
					<p style="padding-left:100px;font-size:20px;">这将是你进行考试的凭证。</p>
					<p style="padding-left:100px;font-size:20px;">请不要进行乱涂乱画。</p>
					<p style="padding-left:100px;font-size:20px;">如果提交信息出错，请联系我们！</p>
					<p style="padding-left:100px;font-size:20px;">QQ:728838939 </p>
					<br>
					<p align="center">--大学生科技创新协会--</p>
				</div>
 			';
 			?><p align="center"><a href="<?php echo "show.php?userid=".$userid ?>" style="font-size:30px; color:red;">查看报名信息</a></p>
 			<?php

		}else if(($aa==0)&&($bb==0)){
			$sql = "insert into member(id, username, usersex, userid, userids, userphone, userxibie, userclass, usertime) values(null, ?, ?, ?, ?, ?, ?, ?, ?)";
			$stmt = $pdo->prepare($sql);
				$username = $_POST['username'];
				$usersex  = $_POST['usersex'];
				$userid   = $_POST['userid'];
				$userids  = $_POST['userids'];
				$userphone= $_POST['userphone'];
				$userxibie= $_POST['userxibie'];
				$userclass= $_POST['userclass'];
				$usertime = time();
			$stmt->bindValue(1, $username);
			$stmt->bindValue(2, $usersex);
			$stmt->bindValue(3, $userid);
			$stmt->bindValue(4, $userids);
			$stmt->bindValue(5, $userphone);
			$stmt->bindValue(6, $userxibie);
			$stmt->bindValue(7, $userclass);
			$stmt->bindValue(8, $usertime);
			$stmt -> execute();
			//echo $stmt->rowCount();
			
			echo '
				<div>
					<h1 align="center">你好！你已成功提交信息，点击查看信息查看报名信息。</h1>
					<br>
					<p style="padding-left:100px;font-size:22px;>请将查看页面进行截图。</p>
					<p style="padding-left:100px;font-size:20px;">这将是你进行考试的凭证。</p>
					<p style="padding-left:100px;font-size:20px;">请不要进行乱涂乱画。</p>
					<p style="padding-left:100px;font-size:20px;">如果提交信息出错，请联系我们！</p>
					<p style="padding-left:100px;font-size:20px;">QQ:728838939 </p>
					<br>
					<p align="center">--大学生科技创新协会--</p>
				</div>
				
 			';
 			?><p align="center"><a href="<?php echo "show.php?userid=".$userid ?>" style="font-size:30px; color:red;">查看报名信息</a></p>
 			<?php
		}



		
		//查错代码
		echo "<br>";
		echo $pdo->errorCode();
		echo "<br>";
		print_r($pdo->errorInfo());

	}catch(PDOException $e){
		$e->getMessage();
	}
?>

